Repository navigation
fix: generate complete padded ngrams for short sequences - #805
Open
xiaoyao-666-coder wants to merge 1 commit into
Open
xiaoyao-666-coder wants to merge 1 commit into
xiaoyao-666-coder wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
NGrams.trigrams('hello', '[start]', '[end]')currently returns four arrays, including['[start]', 'hello']and['hello', '[end]'], which are not trigrams. It also misses['[start]', 'hello', '[end]'].NGramsZHhas the same problem. Independently generating the two padded ends assumes that the input has at leastn - 1tokens.Pad the sequence with
n - 1copies of each requested boundary symbol before taking complete windows. A shared internal helper keeps word and Chinese n-grams consistent, preserves caller arrays, and leaves unpadded inputs alone. Existing statistics now count the complete windows as well.The one-word example now produces:
Companion documentation for the
gh-pagesbranch: #806.Validation
On Windows with Node.js 24.22.1:
master, 16 fail; all pass with this change.npm run build:testsandnpm testpass: 916 specs, zero failures.npm run lint,npm run build:esm, andnpm run smoke:esmpass.git diff --checkpasses.The database-backed I/O suite was not run locally.
Checklist before merging
Prepared with Codex assistance.